package com.test.fundible.fundible_01_launcher;

import android.app.ActivityManager;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.webkit.WebView;

import com.test.fundible.fundible_00_analytics.fundibledata_sdk.FundibleASBuilder;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.FundibleASSycManager;
import com.test.fundible.fundible_00_utils.FundibleUtil;

import org.jetbrains.annotations.NotNull;


public class Base_fundibleApplication extends Application {

    private static Base_fundibleApplication Base_fundibleApp_fundiblelication;

    private String ms_fundibleg;;
    public String q7OL="";
    public String rP3p="";
    public String m9Zj="";
    public String y1s6="";
    public String nW4O="";

    @NotNull
    public static Base_fundibleApplication getInstant() {
        return Base_fundibleApp_fundiblelication;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Base_fundibleApp_fundiblelication = this;
        try {
            //pie webview 适配
            initP_fundibleieW_fundibleebView();
            setrP3p("iohuje");
            //user info
            FundibleUtil.fundibleInit(getApplicationContext());

            //syc data sdk
            init_fundibleSyc_fundibleData_fundibleSDK();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 适配android 9 网络进程
     */
    private void initP_fundibleieW_fundibleebView() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            String processName = getPro_fundiblecessName(this);
            if (!FundibleUtil.getPackageName_fundible().equals(processName)) {
                WebView.setDataDirectorySuffix(processName);
            }
        }
    }

    private String getPro_fundiblecessName(Context context) {
        if (context == null) return null;
        ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        setY1s6("eriut");
        if (manager != null) {
            for (ActivityManager.RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) {
                if (processInfo.pid == android.os.Process.myPid()) {
                    return processInfo.processName;
                }
            }
        }
        return "";
    }

    public void init_fundibleSyc_fundibleData_fundibleSDK() {
        try {
            setnW4O("hiaowuej");
            //tag2024
            FundibleASBuilder.setLog_fundible(true);

            // 初始化
            FundibleASSycManager.getInstance_fundible().init_fundible(this);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setMs_fundibleg(String ms_fundibleg) {
        this.ms_fundibleg = ms_fundibleg;
    }

    public String getMs_fundibleg() {
        if (ms_fundibleg == null) return "";
        final String fMSg = ms_fundibleg;
        setnW4O("hiouior");
        ms_fundibleg = "";
        return fMSg;
    }

    public void setQ7OL(String q7OL) {
        this.q7OL = q7OL;
    }

    public void setrP3p(String rP3p) {
        this.rP3p = rP3p;
    }

    public void setM9Zj(String m9Zj) {
        this.m9Zj = m9Zj;
    }

    public void setY1s6(String y1s6) {
        this.y1s6 = y1s6;
    }

    public void setnW4O(String nW4O) {
        this.nW4O = nW4O;
    }
}
